const express = require('express')
const output = require('./middleware/output')

const app = express()
const PORT = 3003

// 设置允许跨域访问该服务
app.all('*', function (req, res, next) {
    res.header("Access-Control-Allow-Origin", "*");
    res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
    res.header("Access-Control-Allow-Headers", "X-Requested-With");
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    next();
});

app.use(output)

const router = require('./router')
app.use('/api', router)

app.listen(PORT, () => {
    console.log(`Server running at http://127.0.0.1:${PORT}`)
})